﻿//------------------------------------------------------------
// VRLauncher
// Copyright © 2024-2025.1 Song Ding
// UI列表的业务控制基类
//------------------------------------------------------------
using UnityEngine;
using UnityGameFramework.Runtime;

namespace VRLauncher
{
    public abstract class EntityFromListObject : EntityLogic
    {
        [SerializeField]
        private EntityFromListObjectData m_EntityFromListObjectData = null;
#if UNITY_2017_3_OR_NEWER
        protected override void OnInit(object userData)
#else
        protected internal override void OnInit(object userData)
#endif
        {
            base.OnInit(userData);
        }

#if UNITY_2017_3_OR_NEWER
        protected override void OnShow(object userData)
#else
        protected internal override void OnShow(object userData)
#endif
        {
            base.OnShow(userData);

            m_EntityFromListObjectData = userData as EntityFromListObjectData;
            if (m_EntityFromListObjectData == null)
            {
                Log.Error("Armor data is invalid.");
                return;
            }
            //设置UI父物体
            CachedTransform.SetParent(m_EntityFromListObjectData.ParentUI,false);
            CachedTransform.localPosition = m_EntityFromListObjectData.Position;
            CachedTransform.localRotation = m_EntityFromListObjectData.Rotation;
            CachedTransform.localScale = Vector3.one;
        }
    }
}
